package mode.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * jdk代理模式测试
 *
 * @author xjx
 * @date 2023/7/19 15:17
 */
public class MainTest {
    public static void main(String[] args) {
        MainTest test = new MainTest();
        test.getProxy();
    }

    public void getProxy() {
        Server sinaServer = new SinaServer();
        InvocationHandler invocationHandler = new NginxInvocationHandler(sinaServer);
        Server proxy = (Server) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Server.class}, invocationHandler);

        System.out.println(proxy.getPageTitle("http://www.sina.com.cn/"));
    }
}
